﻿using PetaPoco;
using PmSoft;
using PmSoft.Caching;
using System.ComponentModel;

namespace Modules.System.Attachment
{
    /// <summary>
    /// 附件
    ///</summary>
    [TableName("sys_attachment")]
    [Description("附件信息表")]
    [PrimaryKey("id", AutoIncrement = false)]
    [CacheSetting(true)]
    [Serializable]
    public class AttachmentInfo : IDelEntity
    {
        /// <summary>
        /// 附件ID
        ///</summary>
        [Column("id")]
        public string Id { get; set; }

        /// <summary>
        /// 文件名称
        ///</summary>
        [Column("name")]
        public string Name { get; set; }

        /// <summary>
        /// 桶名称
        /// </summary>
        [Column("bucket_name")]
        public string BucketName { get; set; }

        /// <summary>
        /// 对象名称，包含路径
        /// </summary>
        [Column("object_file_path")]
        public string ObjectFilePath { get; set; }

        /// <summary>
        /// 友好的文件名称
        ///</summary>
        [Column("friendly_name")]
        public string FriendlyName { get; set; }

        /// <summary>
        /// 媒体类型
        ///</summary>
        [Column("media_type")]
        public MediaType MediaType { get; set; }

        /// <summary>
        /// 附件MIME类型
        ///</summary>
        [Column("content_type")]
        public string ContentType { get; set; }

        /// <summary>
        /// 文件大小字节
        ///</summary>
        [Column("file_length")]
        public long? FileLength { get; set; }

        /// <summary>
        /// 上传者IP
        ///</summary>
        [Column("ip")]
        public string Ip { get; set; }

        /// <summary>
        /// 排序ID
        ///</summary>
        [Column("display_order")]
        public int? DisplayOrder { get; set; }

        /// <summary>
        /// 附件描述
        ///</summary>
        [Column("discription")]
        public string Discription { get; set; }

        /// <summary>
        /// 创建时间
        /// 默认值: 0000-00-00 00:00:00
        ///</summary>
        [Column("create_time")]
        public DateTime CreateTime { get; set; } = DateTime.Now;
        /// <summary>
        /// 是否已删除
        /// 默认值: b'0'
        ///</summary>
        [Column("is_deleted")]
        public bool IsDeleted { get; set; }=false;
        /// <summary>
        /// 是否临时文件
        /// </summary>
        [Column("is_temporary")]
        public bool IsTemporary { get; set; }
        [Ignore]
        bool IDelEntity.IsDeletedInDatabase { get => IsDeleted; set => IsDeleted = value; }

        #region IEntity 成员

        [Ignore]
        object IEntity.EntityId { get { return this.Id; } }

        #endregion IEntity 成员
    }
}